{% set page_title = _("Memberlist") %}

{% extends theme("layout.html") %}
{% block content %}
{% from theme('macros.html') import render_pagination, input_group_field %}

{% set order_by = 'desc' if request.args.get('order_by') == 'asc' else 'asc' %}
{% set sort_by = request.args.get('sort_by') %}

<div class="page-view">
    <ol class="breadcrumb flaskbb-breadcrumb">
        <li><a href="{{ url_for('forum.index') }}">{% trans %}Forum{% endtrans %}</a></li>
        <li class="active">{% trans %}Memberlist{% endtrans %}</li>
    </ol>

    <div class="row controls-row">
        <div class="col-md-8 col-sm-8 col-xs-8 controls-col">
            <div class="pull-left">
                {{ render_pagination(users, url_for('forum.memberlist'), sort_by=sort_by, asc=(order_by == 'desc')) }}
            </div>
        </div>
        <div class="col-md-4 col-sm-4 col-xs-4 controls-col">
            <div class="pull-right">
                <form class="inline-form" role="form" method="post">
                    {{ search_form.hidden_tag() }}
                    <div class="input-group">
                        {{ input_group_field(search_form.search_query) }}
                        <span class="input-group-btn">
                            <button class="btn btn-primary" type="submit">{% trans %}Search{% endtrans %}</button>
                        </span>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <div class="panel page-panel">
        <div class="panel-heading page-head">
            <a href="{{ url_for('forum.memberlist') }}">{% trans %}Memberlist{% endtrans %}</a>
        </div>
        <div class="panel-body page-body">
            <div class="page-meta">
                <div class="col-md-1 col-sm-1 col-xs-1 meta-item">#</div>
                <div class="col-md-3 col-sm-3 col-xs-5 meta-item">
                    <a href="{{ url_for('forum.memberlist') }}?sort_by=username&order_by={{ order_by }}">{% trans %}Username{% endtrans %}</a>
                </div>
                <div class="col-md-3 col-sm-3 hidden-xs meta-item">
                    <a href="{{ url_for('forum.memberlist') }}?sort_by=reg_date&order_by={{ order_by }}">{% trans %}Date registered{% endtrans %}</a>
                </div>
                <div class="col-md-3 col-sm-3 col-xs-5 meta-item">{% trans %}Group{% endtrans %}</div>
                <div class="col-md-2 col-sm-2 hidden-xs meta-item">
                    <a href="{{ url_for('forum.memberlist') }}?sort_by=post_count&order_by={{ order_by }}">{% trans %}Posts{% endtrans %}</a>
                </div>
            </div>
            {% for user in users.items %}
            <div class="row page-row hover clearfix">
                <div class="col-md-1 col-sm-1 col-xs-1">{{ user.id }}</div>
                <div class="col-md-3 col-sm-3 col-xs-5"><a href="{{ user.url }}">{{ user.username }}</a></div>
                <div class="col-md-3 col-sm-3 hidden-xs">{{ user.date_joined|format_datetime }}</div>
                <div class="col-md-3 col-sm-3 col-xs-5">{{ user.primary_group.name }}</div>
                <div class="col-md-2 col-sm-2 hidden-xs">{{ user.post_count }}</div>
            </div>
            {% endfor %}
        </div>
    </div>
</div>
{% endblock %}
